package com.xuxueli.applyModules.commont;
import com.xuxueli.applyModules.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;

import java.util.Date;

/**
 * 实现Job接口
 * @author yvan
 *
 */
@Slf4j
public class SchedulerQuartzJob2 implements Job{
    private void before(){
        System.out.println("任务开始执行");
    }

    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        before();
        System.out.println("开始："+System.currentTimeMillis());
        JobKey jobKey = arg0.getJobDetail().getKey();
        log.info("定时任务开始: {},{}", jobKey.getGroup(), jobKey.getName());
        Date date = new Date(System.currentTimeMillis());
        System.out.println(jobKey.getGroup()+ DateUtils.formatDate(date,"yyyy-MM-dd HH:mm:ss"));
        // TODO 业务
        System.out.println("结束："+System.currentTimeMillis());
        after();
    }

    private void after(){
        System.out.println("任务开始执行");
    }

}
